package com.yunhe.javabean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

//订单类
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Orders {
    private int id;
    private String orderNum;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date orderTime;
    private int peopleCount;
    private String orderDesc;
    private int payType;//'支付方式（0 支付宝 1微信 2 其他',
    private int orderStatus;// '订单状态（0未支付1已支付）',
    private int productId;// '产品id外键',
    private int memberId;// '会员（联系人）id外键',
    private String payTypeStr;
    private String orderStatusStr;
    private Product product;
    private Member member;
    private List<Traveller> travellers;


    public String getOrderTimeStr() {
        String departureTimeStr="";
        // 对日期格式化
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        if (null != orderTime) {
            departureTimeStr = dateFormat.format(orderTime);
        }
        return departureTimeStr;
    }


    public String getPayTypeStr() {

        if (payType == 0) {
            payTypeStr = "支付宝";
        } else if (payType == 1) {
            payTypeStr = "微信";
        } else if (payType == 2) {
            payTypeStr = "其他";
        }
        return payTypeStr;
    }

    public String getOrderStatusStr() {

        if (orderStatus == 0) {
            orderStatusStr = "未支付";
        } else if (orderStatus == 1) {
            orderStatusStr = "已支付";
        }
        return orderStatusStr;
    }
}
